let list = [{
  name: '老师名字',
  value: ''
}, {
  name: '开始时间',
  value: ''
}, {
  name: '教程名',
  value: ''
}, {
  name: '第几课',
  value: ''
}, {
  name: '标题',
  value: ''
}, {
  name: '页数',
  value: ''
}, {
  name: '重点句型',
  value: ''
}, {
  name: '语法项目',
  value: ''
}, {
  name: '作业',
  value: ''
}, {
  name: '下次何处开始',
  value: ''
},]


let createHistoryWrap = async () => {
  await getCourseHistory()
  $('.detail-content')[0] && $('.detail-content')[0].remove()
  //老师课程记录 内容
  let section_content = document.createElement("section");
  //老师课程记录 内容 列表
  let section_footer = document.createElement("section");
  section_content.className = "detail-content";
  section_footer.className = "detail-content-list-wrap";
  for (let i = 0; i < list.length; i++) {
    let s2 = document.createElement("section");
    s2.className = "detail-content-list";
    s2.innerHTML = `
            <div class="detail-content-list-title">${list[i].name}</div>
            <div class="detail-content-list-subtitle">${list[i].value}</div>
        `;
    section_footer.appendChild(s2);
  }
  $(".section-course_history-detail")[0].appendChild(section_content);
  section_content.appendChild(section_footer);
};

let getCourseHistory = async () => {
  let params = {}
  if (window.location.href.split('/')) {
    let location = window.location.href.split('/')[6].split('?')[1].split('&')
    location.forEach(item => {
      let key = item.split('=')[0]
      let value = item.split('=')[1]
      params[key] = value
    })
    let res = await ajax('student_query_curriculum_record', params, 'post')
    if (res.data.length) {
      list[0].value = res.data[0].teachername + '老师'
      list[1].value = res.data[0].createtime
      list[2].value = res.data[0].tutorialname + '教程'
      list[3].value = res.data[0].whatclass + '课'
      list[4].value = res.data[0].title
      list[5].value = res.data[0].pagequantity + '页'
      list[6].value = res.data[0].keysentences
      list[7].value = res.data[0].grammaritem
      list[8].value = res.data[0].task
      list[9].value = res.data[0].startnexttime
    }
    console.log(res)
  }

}

export { createHistoryWrap };
